const Router = require("@koa/router");
const router = new Router({ prefix: "/order" });
const { auth } = require("../middleware/authMiddleware");
const { validator } = require("../middleware/orderMiddleware");
const { create, findAll, update } = require("../controller/orderController");
// 1. 提交订单
router.post(
  "/",
  auth,
  validator({
    address_id: "int",
    goods_info: "string",
    total: "string",
  }),
  create
);
// 2. 获取订单列表
router.get("/", auth, findAll);
// 3. 更新订单状态
router.patch(
  "/:id",
  auth,
  validator({
    status: "number",
  }),
  update
);
module.exports = router;
